<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>load() 1 column</title>

  <link rel="stylesheet" href="../../../demo/demo.css"/>
  <script src="../../../dist/gridstack-all.js"></script>

</head>
<body>
  <div class="container-fluid">
    <h1>load() 1 column</h1>
    <p>resize to below 768px, reload, then expand up to check 12 column</p>
    <div>
      <a class="btn btn-primary" onClick="addNewWidget()" href="#">Add Widget</a>
      <a class="btn btn-primary" onclick="toggleFloat()" id="float" href="#">float: true</a>
    </div>
    <br><br>
    <div class="grid-stack"></div>
  </div>
  <script src="../../../demo/events.js"></script>
  <script type="text/javascript">
    let grid = GridStack.init({float: true});
    addEvents(grid);

    let items = [
      {x: 1, y: 0, w: 2, content: '0'},
      {x: 3, y: 1, h: 2, content: '1'},
      {x: 4, y: 1, content: '2'},
      {x: 2, y: 3, w: 3,content: '3'},
      {x: 0, y: 6, w: 2, h: 2, content: '4'}
    ];
    grid.load(items);

    addNewWidget = function() {
      let n = items[count] || {
        x: Math.round(12 * Math.random()),
        y: Math.round(5 * Math.random()),
        w: Math.round(1 + 3 * Math.random()),
        h: Math.round(1 + 3 * Math.random())
      };
      n.content = String(count++);
      grid.addWidget(n);
    };

    toggleFloat = function() {
      grid.float(! grid.getFloat());
      document.querySelector('#float').innerHTML = 'float: ' + grid.getFloat();
    };
  </script>
</body>
</html>
